package com.dorm.cj.extension.factoryBean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.stereotype.Service;

@Service
public class TestFactoryBeanService  implements BeanFactoryAware {

    private BeanFactory beanFactory;

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        this.beanFactory=beanFactory;
    }

    public void test(){
        //获取FactoryBean.getObject()对象
        Object testFactoryBean = beanFactory.getBean("testFactoryBean");
        System.out.println(testFactoryBean);
        //获取真实的FactoryBean对象
        Object testFactoryBean2 = beanFactory.getBean("&testFactoryBean");
        System.out.println(testFactoryBean2);
    }
}
